#pragma once
#include <boost/filesystem/path.hpp>
#include "TerrainTileSetFwd.hpp"
#include "TerrainTileSplatFwd.hpp"
#include "ImportExport.hpp"

namespace he
{
	//! Terrain material manager.
	/*!
		There is one assumption when defining materials. Each main terrain type (i.e. summer, winter, ...) must be in one texture and must have same textures and same
		texture coordinates for sub-types/indices as other main terrain types (It means that each terrain texture atlas must be composed of the same number of texture,
		with same dimensions and with same settings.
	*/
	class TerrainMaterialManager
	{
		// Typedefs		
	private:
		//! Map between the terrain category and TerrainMaterial.
		typedef std::map<std::string, TerrainTileSetPtr_t> MaterialMap_t;
		//! Map of terrain splats.
		typedef std::map<unsigned short, TerrainTileSplatPtr_t> TerrainSplatMap_t;

		// Attributes
	private:
		//! Material map.
		MaterialMap_t m_MaterialMap;
		//! Map of all splats.
		TerrainSplatMap_t m_TerrainSplatMap;

		// Operations
	public:
		//! Get terrain material based on terrain category.
		HE_ENGINE_API TerrainTileSet const &get_terrain_set(std::string const &Category) const;
	private:
		//! Get material.
		Ogre::MaterialPtr get_material(std::string const &MaterialName);

		// Construction/Destruction
	public:
		//! Load the terrain xml file.
		HE_ENGINE_API TerrainMaterialManager(boost::filesystem::path const &Path);
	};
}